跳转至

PyMdown 扩展语法

Python Markdown 扩展官方文档: pymdown-extensions

Admonition

官方链接: admonitions

基础用法

1
2
3
!!! note 

    这是一个 note 

Note

这是一个 note

1
2
3
!!! note "标题"

    带标题

标题

带标题

1
2
3
!!! note ""

    无标题

无标题

1
2
3
??? note "折叠"

    可折叠
折叠

可折叠

1
2
3
???+ note "展开"

    展开
展开

展开

Lorem ipsum

!!! info inline "Lorem ipsum"

1111

Lorem ipsum

!!! info inline "Lorem ipsum"

1111


支持的类型

Note

Abstract

Info

Tip

Success

Question

Warning

Failure

Danger

Bug

Example

Quote


code block

官方链接: code-blocks

基础用法

1
2
3
``` py
import tensorflow as tf
```
import tensorflow as tf
1
2
3
4
5
6
7
``` py title="bubble_sort.py"
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
```
bubble_sort.py
1
2
3
4
5
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
1
2
3
4
5
``` python
print("hello")  # (1)!
```

1. 这是注释
print("hello")  # (1)!
  1. 这是注释

放置在代码块中可以添加代码块语言注释的地方

1
2
3
4
5
6
7
``` py linenums="0"
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
```
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
1
2
3
4
5
6
7
``` py hl_lines="2 3"
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
```
1
2
3
4
5
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]

tabbed

官方链接: tabbed

=== "Tab 1"
    Markdown **content**.

    Multiple paragraphs.

=== "Tab 2"
    More Markdown **content**.

    - list item a
    - list item b

Markdown content.

Multiple paragraphs.

More Markdown content.

  • list item a
  • list item b
=== "Tab 1"
    Markdown **content**.

    Multiple paragraphs.

=== "Tab 2"
    More Markdown **content**.

    - list item a
    - list item b

===! "Tab A"
    Different tab set.

=== "Tab B"
    More content.

Markdown content.

Multiple paragraphs.

More Markdown content.

  • list item a
  • list item b

Different tab set.

More content.
=== "Not Me"
    Markdown **content**.

    Multiple paragraphs.

===+ "Select Me"
    More Markdown **content**.

    - list item a
    - list item b

=== "Not Me Either"
    Another Tab

Markdown content.

Multiple paragraphs.

More Markdown content.

  • list item a
  • list item b

Another Tab

formatting

1
2
3
- ==This was marked (highlight)==
- ^^This was inserted (underline)^^
- ~~This was deleted (strikethrough)~~
  • This was marked (highlight)
  • This was inserted (underline)
  • This was deleted (strikethrough)
- H~2~O
- A^T^A
  • H2O
  • ATA
++ctrl+alt+del++

Ctrl+Alt+Del

grids

1
2
3
4
5
6
7
8
<div class="grid cards" markdown>

- :fontawesome-brands-html5: __HTML__ for content and structure
- :fontawesome-brands-js: __JavaScript__ for interactivity
- :fontawesome-brands-css3: __CSS__ for text running out of boxes
- :fontawesome-brands-internet-explorer: __Internet Explorer__ ... huh?

</div>
  • HTML for content and structure
  • JavaScript for interactivity
  • CSS for text running out of boxes
  • Internet Explorer ... huh?
<div class="grid cards" markdown>

-   :material-clock-fast:{ .lg .middle } __标题 1__

    ---

    Install [`链接`](#) with [`pip`](#) 

    [:octicons-arrow-right-24: Getting started](#)

-   :fontawesome-brands-markdown:{ .lg .middle } __标题 2__

    ---

    xxx

</div>
  • Sed sagittis eleifend rutrum
  1. Sed sagittis eleifend rutrum
Content tabs
1
2
3
4
5
6
7
=== "Unordered list"

    * Sed sagittis eleifend rutrum

=== "Ordered list"

    1. Sed sagittis eleifend rutrum

button

[Subscribe to our newsletter](#){ .md-button }

Subscribe to our newsletter

[Subscribe to our newsletter](#){ .md-button .md-button--primary }

Subscribe to our newsletter

[Send :fontawesome-solid-paper-plane:](#){ .md-button }

Send

其他

1
2
3
4
5
6
7
8
!!! note annotate "Phasellus posuere in sem ut cursus (1)"

Lorem ipsum dolor sit amet, (2) consectetur adipiscing elit. Nulla et
euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo
purus auctor massa, nec semper lorem quam in massa.

1.  :man_raising_hand: I'm an annotation!
2.  :woman_raising_hand: I'm an annotation as well!

Phasellus posuere in sem ut cursus (1)

Lorem ipsum dolor sit amet, (2) consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.

  1. 🙋‍♂️ I'm an annotation!
  2. 🙋‍♀️ I'm an annotation as well!
[预览](Python%20Markdown%20扩展语法/#_1){ data-preview }

预览

  • 高亮:This was marked
  • 下划线:This was inserted
  • 删除线:This was deleted

  • 下标:H2O

  • 上标:ATA

  • 键盘:Ctrl+Alt+Del

  • This was marked
  • This was inserted
  • This was deleted
  • H2O
  • ATA
  • Ctrl+Alt+Del